<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head th:replace="mobile/common::head"></head>
<body>

<header>
    <!--页面顶部内容,登录登出等信息-->
    <div th:replace="mobile/common::page-top"></div>
    <!--搜索导航-->
    <div th:replace="mobile/common::search-nav"></div>

    <!--目录内容-->
    <div id="itemBox" style="width: 100%">
        <div th:each="product : ${productList}" class="item-box">
            <a th:href="@{${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName()} + '/page/detail/' + ${product.id} }">
                <img th:src="${product.image}" width="80px" style="float: left">
                <div class="item-box-content">
                    <p th:text="${product.productNo}" style="color: #1E9FFF"></p>
                    <p th:text="${product.catalogEnname}"></p>
                    <div style="width: 100%">
                        <b style="float: left" th:each="oem : ${product.oemList}" th:text="${oem.brand +':' + oem.refNo + ';'}"></b>
                    </div>
                </div>
                <div style="clear: both"></div>
            </a>
        </div>
        <!--翻页器-->
        <div id="pagehelper"></div>
    </div>
</header>

<!--页脚-->
<div th:replace="mobile/common::footer"></div>

</body>

<script>
    layui.use('laypage', function(){
        var laypage = layui.laypage;

        //执行一个laypage实例
        let p=window.location.href.split('?')[1]
        let params=new URLSearchParams(p)
        laypage.render({
            elem: 'pagehelper', //注意，这里的 test1 是 ID，不用加 # 号
            count: [[${page.totalCount}]], //数据总数，从服务端得到
            limit: [[${page.pageSize}]]?[[${page.pageSize}]]:10, //数据总数，从服务端得到
            curr: params.get("pageNum")?params.get("pageNum"):1,//当前页
            limits:[10, 20, 30, 40, 50],
            layout:['limit','prev', 'page', 'next'],
            jump: function(obj, first){
                //obj包含了当前分页的所有参数，比如：
                //首次不执行
                if(!first){
                    //do something
                    var param = location.search;			//search获得地址中的参数，内容为'?itemId=12'
                    var result = param.match(/[^\?&]*=[^&]*/g); 	//match是字符串中符合的字段一个一个取出来，result中的值为['login=xx','table=admin']
                    param = {};					//让paras变成没有内容的json对象
                    for(i in result){
                        var temp = result[i].split('=');	//split()将一个字符串分解成一个数组,两次遍历result中的值分别为['itemId','xx']
                        param[temp[0]] = temp[1];
                    }
                    param.pageNum = obj.curr
                    param.limit = obj.limit
                    let url = window.location.pathname + "?"
                    for(let key  in param){
                        let str = key + "=" + param[key] + "&"
                        url+=str
                    }
                    window.location.href = url.substring(0,url.length - 1);
                }
            }
        });
    });
</script>
<script type="text/javascript" th:src="@{/static/index/js/text.js}"></script>
<script type="text/javascript" th:src="@{/static/index/js/header.js}"></script>
<script type="text/javascript" th:src="@{/static/index/js/secend.js}"></script>
<script type="text/javascript" th:src="@{/static/index/js/index.js}"></script>
<script type="text/javascript" th:src="@{/static/index/js/left,top.js}"></script>
<script type="text/javascript" th:src="@{/static/index/js/catalogLoader.js}"></script>
</html>
